package com.happe.foodeasy.dto;

import com.happe.foodeasy.system.entity.LinkedImage;
import org.apache.commons.beanutils.PropertyUtils;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;

public class LinkedImageDTO {
    private long id;
    private String targetUrl;
    private String imageName;
//    private String imageTargetPositionName;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getTargetUrl() {
        return targetUrl;
    }

    public void setTargetUrl(String targetUrl) {
        this.targetUrl = targetUrl;
    }

    public String getImageName() {
        return imageName;
    }

    public void setImageName(String imageName) {
        this.imageName = imageName;
    }

    public static List<LinkedImageDTO> sourceToDTO(List<LinkedImage> linkedImages) {
        List<LinkedImageDTO> dtoes = new ArrayList<>();
        for (LinkedImage linkedImage : linkedImages) {
            LinkedImageDTO dto = new LinkedImageDTO();
            try {
                PropertyUtils.copyProperties(dto, linkedImage);
            } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
                throw new RuntimeException(e);
            }
            dtoes.add(dto);
        }

        return dtoes;
    }

//    public String getImageTargetPositionName() {
//        return imageTargetPositionName;
//    }
//
//    public void setImageTargetPositionName(String imageTargetPositionName) {
//        this.imageTargetPositionName = imageTargetPositionName;
//    }
}
